﻿
//ajax分页

$(document).ready(function(){

/*var histor = new Array();
function putCurrentPage(e)
{
	var s =e.currentPage;
	if(window.histor[s]){
		showData(histor[s],s);
	}else{
		$.ajax({
			url:'ajaxPage',
			type:'post',
			dataType:'json',
			data:{'params':e},
			success:function (data,s)
			{
				showData(data);
			},
		});
	}
	
}

function showData(data,e)
{
	if(!window.histor[e])
	{
		histor[e] = data;
	}
	var frist = '<tr class="list_menu">';
	frist += $(".warp table tr:nth-child(1)").html();
	frist += '</tr>';
	$(".warp table").empty().append(frist+data.tableStr).fadeIn(1000);
	$(".pageCss").remove();
	$(".warp").append(data.pageStr).fadeIn(1000);
}*/

$('#post').click(function(){
	alert("dsfsd");
	var content = "dsfd";
	var commentName = $("input[name=commName]").val();
	var commentEmail = $("input[name=email]").val();
	var commentUrl = $("input[name=url]").val();
	$.ajax({
		url:"comment",
		dataType:"text",
		type:"post",
		data:{"content":content,"name":commentName,"email":commentEmail,"url":commentUrl},
		success:function(data)
		{
			alert(data);
		}
	});	
})

$('input[name=commentSubmit]').click(function()
	{
		var name = $('#CommentForm_name').val();
		var content = editor.html();
		var email = $('#CommentForm_email').val();
		var blog_url = $('#CommentForm_blog_url').val();
		var data = {"name":name,"email":email,"blog_url":blog_url};
		$.ajax({
			url:'comment',
			dataType:'text',
			type:'post',
			data:{"CommentForm":data,'content':content},
			success:function(data)
			{	alert(data);
				if(data!=0)
				{
					alert("发表成功");
				}else{
					alert("发表失败");
				}
			}
		});
	});


	KindEditor.ready(function(K) 
	{
		// 创建编辑框
		editor = K.create('#CommentForm_content',
		{
			resizeType : 1,
			allowPreviewEmoticons : false,
			allowImageUpload : true,
			afterUpload : function(data){
				imgUrlArray[count] = data;
				count++;
			},
			items :
			[
				'source', '|','code','|','justifyleft',
		        'justifycenter','justifyright','|','fontname','fontsize','|',
		        'forecolor','hilitecolor','bold','italic','underline','strikethrough',
		        'table','emoticons', 'link'
		        
		        
			]
		});

		/*初始化编辑框
		editor.html();*/
	})

})




